package com.example.yblin.hello24.DataUtils;

import android.content.Context;

import java.util.HashMap;
import java.util.Map;

public class RegisterUtil {


    public static int register(String username, String password, Context context) {

        //构建列表
        Map<String, String> userInfoList = new HashMap<>();
        userInfoList.put("username", username);
        userInfoList.put("pwd", password);

        NetUtil netUtil = new NetUtil(NetUtil.ADDR_REGISTER, userInfoList);

        Map<String, String> returnData = netUtil.getData();
        //在此执行网络异常处理
        if (returnData.get("code").equals("" + NetUtil.CODE_OK)) {
            LoginUtil.login(username, password, context);
            return NetUtil.CODE_OK;
        } else {
            return Integer.parseInt(returnData.get("code"));
        }


    }
}
